package com.glorystone.ins.controller;

import com.glorystone.ins.common.common.DataTable;
import com.glorystone.ins.common.common.PageVo;
import com.glorystone.ins.domain.Log;
import com.glorystone.ins.domain.Product;
import com.glorystone.ins.interceptor.PageList;
import com.glorystone.ins.service.LogSvr;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

import static com.glorystone.ins.controller.BaseController.parametToPageVo;
import static com.glorystone.ins.controller.BaseController.resultToDataTable;

/**
 * 项目名称：ins
 * 类名称：LogCtr
 * 类描述：
 * 创建人：zgh
 * 创建时间：2018/4/11 11:31
 */
@Slf4j
@Controller
@RequestMapping("/sysLog")
public class LogCtr {

    @Autowired
    private LogSvr logSvr;

    /**
     * 去日志列表
     * @return
     */
    @RequestMapping("/toLogList")
    public String toLogList(){
        return "/log/logList";
    }


    /**
     * 获取所有日志
     * @return
     */
    @RequestMapping("/getList")
    @ResponseBody
    public DataTable<Log> getLogList(HttpServletRequest request){
        PageVo vo =  parametToPageVo(request, Log.class);
        PageList<Log> list = logSvr.getLogList(vo);
        DataTable data = resultToDataTable(list);
        return data;
    }
}
